package com.bawei.module_live.adapter

import android.view.LayoutInflater
import android.view.View
import android.view.ViewGroup
import android.widget.ImageView
import android.widget.TextView
import androidx.recyclerview.widget.RecyclerView
import com.bawei.module_live.R
import com.bawei.module_live.version1.HourRankEntity

class HourRankAdapter(private val list: List<HourRankEntity>) : RecyclerView.Adapter<HourRankAdapter.HourRankViewHolder>() {
    override fun onCreateViewHolder(parent: ViewGroup, viewType: Int): HourRankViewHolder {
        val view = LayoutInflater.from(parent.context).inflate(R.layout.item_hour_rank, parent, false)
        return HourRankViewHolder(view)
    }
    override fun onBindViewHolder(holder: HourRankViewHolder, position: Int) {
        val item = list[position]
        holder.ivAvatar.setImageResource(item.avatar)
        holder.tvName.text = item.username
        holder.tvHour.text = "${item.hour} 小时"
    }
    override fun getItemCount(): Int = list.size
    class HourRankViewHolder(itemView: View) : RecyclerView.ViewHolder(itemView) {
        val ivAvatar: ImageView = itemView.findViewById(R.id.iv_avatar)
        val tvName: TextView = itemView.findViewById(R.id.tv_name)
        val tvHour: TextView = itemView.findViewById(R.id.tv_hour)
    }
} 